﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Rights_AddAssignRule_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Rights_AddAssignRule_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Rights_AddAssignRule_V2]
    @Act_ID int,
    @Based_On int,
    @Src_ID int,
    @Obj_ID int
/*

============================================================
功能:    添加权限
参数:
    @Act_ID int        :    权限代号
    @Based_On int        :  基于对象
    @Src_ID int        :    拥有权限的对象集合
    @Obj_ID int        :    权限范围

============================================================

*/
AS
BEGIN
SET NOCOUNT ON

--给职位赋予权限
IF @Based_On = 1
    INSERT INTO dbo.UDS_Assign_Rule (act_id, based_on, Position_id, team_id) VALUES(@Act_ID, @Based_On, @Src_ID, @Obj_ID);

--给组赋予权限
IF @Based_On = 2
    INSERT INTO dbo.UDS_Assign_Rule (act_id, based_on, team_id) VALUES(@Act_ID, @Based_On, @Obj_ID);

--给角色赋予权限
IF @Based_On = 3
    INSERT INTO dbo.UDS_Assign_Rule (act_id, based_on, role_id, team_id) VALUES(@Act_ID, @Based_On, @Src_ID, @Obj_ID);

--给个人赋予权限
IF @Based_On = 4
    INSERT INTO dbo.UDS_Assign_Rule (act_id, based_on, staff_id, team_id) VALUES(@Act_ID, @Based_On, @Src_ID, @Obj_ID);
   
RETURN 0;
END
GO